#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "diceroll_12.h"

int main(void)
{
    int dice, roll;
    int sides;
    int status;

    srand((unsigned int)time(0));

    printf("Enter the number of sides per die, 0 to stop: ");
    while (scanf("%d", &sides) == 1 && sides > 0)
    {
        printf("How many dice?\n");
        if ((status = scanf("%d", &dice)) != 1)
        {
            if (status == EOF)
                break;
            else
            {
                printf("You should have entered an integer.");
                puts(" Let's begin again.");

                while (getchar() != '\n')
                    continue;
            }
            printf("How many sides? Enter 0 to quit.\n");
            continue;
        }

        roll = roll_n_dice(dice, sides);

        printf("You have rolled a %d using %d %d-sides dice.\n", roll, dice, sides);
        printf("How many sides? Enter 0 to quit.\n");
    }

    printf("The rollom() function was called %d times.\n", roll_count);
    printf("GOOD FORTUNE TO YOU!\n");

    return 0;
}